package com.jyt.controller;

import com.jyt.response.Result;
import com.jyt.response.ResultCode;
import com.jyt.service.AlgorithmService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description: 选择算法
 * @Author hugh.sun
 * @Date 2021/11/25 8:15
 */
@Api
@Slf4j
@RestController
@CrossOrigin
@RequestMapping("/Algorithm")
public class SelectAlgorithmController {
    @Autowired
    private AlgorithmService algorithmService;

    @GetMapping("/SelectAlgorithm")
    public Result SelectAlgorithm(int a){
        switch (a){
            //第一种：调用组合台算法
            case 1:

                try {
                    algorithmService.combination();
                    return Result.ok();
                } catch (Exception e) {
                    e.printStackTrace();
                    return Result.error(ResultCode.COMMON_FAIL);
                }


            //第二种：调用w3算法
            case 2:
                try {
                    algorithmService.w3();
                    return Result.ok();
                } catch (Exception e) {
                    e.printStackTrace();
                    return Result.error(ResultCode.COMMON_FAIL);
                }
            //第三种：调用W4算法
            case 3:
                try {
                    algorithmService.w4();
                    return Result.ok();
                } catch (Exception e) {
                    e.printStackTrace();
                    return Result.error(ResultCode.COMMON_FAIL);
                }
            //第四种：调用其他
            case 4:
                try {
                    algorithmService.other();
                    return Result.ok();
                } catch (Exception e) {
                    e.printStackTrace();
                    return Result.error(ResultCode.COMMON_FAIL);
                }
            default:
                return Result.error(ResultCode.COMMON_FAIL);
        }
    }
}
